import { getCategory } from '@/api/home'
export default {
  namespaced: true,
  state: {
    categoryList: []
  },
  mutations: {
    setCategoryList (state, list) {
      state.categoryList = list
    }
  },
  actions: {
    async getCategoryList ({ commit }) {
      // 1. 调用接口拿到列表数据
      const res = await getCategory()
      // 2. 提交mutation函数存入state
      commit('setCategoryList', res.data.result)
    }
  }
}

// 找一个合适的地方 调用这个action函数
